package cn.bdqn.service.user;

import cn.bdqn.dao.User.SearchRecordsMapper;
import cn.bdqn.pojo.User.SearchRecords;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class SearchRecordsService {
    @Autowired
    SearchRecordsMapper mapper;

    /**
     * 查询所有搜题记录
     * @param curr 当前页
     * @param size  显示多少条
     * @return
     */
    public IPage selectAll(Integer curr,Integer size,Integer userId){
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("user_id",userId);
        IPage page=new Page(curr,size);
       return mapper.selectPage(page,wrapper);
    }
    //删除全部数据
    public Integer drop(Integer userId) {
        QueryWrapper wrapper=new QueryWrapper();
        wrapper.eq("user_id",userId);
        return mapper.delete(wrapper);
    }
    //添加记录
    public Integer insert(SearchRecords searchRecords){
        return mapper.insert(searchRecords);
    }
}
